package com.tb.service;

import com.tb.mapper.TopicMapper;
import com.tb.model.Topic;
import com.tb.model.TopicExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TopicService {
	@Autowired
	private TopicMapper topicMapper;

	public List<Topic> getTopicList() {
		return topicMapper.selectByExample(null);
	}

	public List<Topic> getHotTopics(){
		return topicMapper.selectHotTopics();
	}

	public void deleteTopicById(Integer topicId) {
		topicMapper.deleteByPrimaryKey(topicId);
	}

	public void addTopic(String word) {
		Topic topic = new Topic();
		topic.setName(word);
		topicMapper.insertSelective(topic);
	}

	public Topic getTopicById(Integer topicId) {
		return topicMapper.selectByPrimaryKey(topicId);
	}
}
